//
//  ITLayoutSubViewVC.m
//  InduceTool
//
//  Created by 魏延龙 on 2020/12/16.
//  Copyright © 2020 魏延龙. All rights reserved.
//

#import "ITLayoutSubViewVC.h"
#import "ITLayoutView1.h"
#import "ITLayoutView2.h"
#import <Masonry/Masonry.h>
@interface ITLayoutSubViewVC ()

@property (nonatomic, strong) ITLayoutView1 *view1;
@property (nonatomic, strong) ITLayoutView2 *view2;
@property (nonatomic, strong) UIView *subView;
@end

@implementation ITLayoutSubViewVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor whiteColor];
    
    
//    [self setupViews];
//
//    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
//    btn.frame = CGRectMake(10, 500,100, 44);
//    [btn setTitle:@"改变大小" forState:UIControlStateNormal];
//    [self.view addSubview:btn];
//    [btn addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
//
//    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeSystem];
//    btn1.frame = CGRectMake(130, 500,100, 44);
//    [btn1 setTitle:@"改变大小" forState:UIControlStateNormal];
//    [self.view addSubview:btn1];
//    [btn1 addTarget:self action:@selector(changeSizeAction) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    scrollView.backgroundColor = [UIColor lightGrayColor];
    scrollView.contentSize = CGSizeMake(self.view.bounds.size.width * 2, self.view.bounds.size.height * 2);
    [self.view addSubview:scrollView];
    
    self.view1 = [[ITLayoutView1 alloc] init];
    self.view1.frame = CGRectMake(10, 100, self.view.bounds.size.width * 2, self.view.bounds.size.height * 2);
    [scrollView addSubview:self.view1];
}

-(void)setupViews {
    self.view1 = [[ITLayoutView1 alloc] init];
    [self.view addSubview:self.view1];
    [self.view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(100);
    }];
}

-(void)btnAction {
    self.subView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
    self.subView.backgroundColor = [UIColor blueColor];
    [self.view1 addSubview:self.subView];
}

-(void)changeSizeAction {
    self.subView.frame = CGRectMake(0, 0, 50, 50); // 会执行view1的layoutSubviews
    // self.subView.frame = CGRectMake(0, 20, 20, 20); // 不会执行view1的layoutSubviews
}

@end
